package com.eling.elcms.travel.webapp.controller;

import com.eling.elcms.core.dao.hibernate.search.SearchCondition;
import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.controller.Msg;
import com.eling.elcms.core.webapp.spring.ModelFilling;
import com.eling.elcms.travel.model.CheckInDinner;
import com.eling.elcms.travel.service.ICheckInDinnerManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;
@Controller
public class CheckInDinnerController extends BaseFormController{

	@Autowired
	private ICheckInDinnerManager dinnerM;
	
	@RequestMapping("/api/checkindinner/save")
    @ResponseBody
	public CheckInDinner save(@ModelAttribute@ModelFilling CheckInDinner dinner){
		return dinnerM.save(dinner);
	}
	
	@RequestMapping("/api/checkindinner/{pkCheckInDinner}/delete")
	@ResponseBody
	public Msg delete(@PathVariable Long pkCheckInDinner){
		dinnerM.remove(pkCheckInDinner);
		return new Msg("删除成功");
	}
	
	@RequestMapping("/api/checkindinner/query")
    @ResponseBody
	public List<CheckInDinner> query(@ModelAttribute CheckInDinner dinner){
		return dinnerM.query(dinner);
	}
	
	@RequestMapping("/api/checkindinner/search*")
	@ResponseBody
	public List<CheckInDinner> search(@ModelAttribute SearchCondition sc,@ModelAttribute CheckInDinner dinner){
		sc.setQueryCondition(dinner);
		return dinnerM.search(sc);
	}	
	
	@RequestMapping("/api/checkindinner/confirm")
    @ResponseBody
	public CheckInDinner confirm(@ModelAttribute@ModelFilling CheckInDinner dinner){
		return dinnerM.confirm(dinner);
	}
	
	/**
	 * 查询餐饮落实
	 * @param dinner
	 * @param startDate
	 * @param endDate
	 * @return
	 * @author zhoulin
	 */
	@RequestMapping("/api/checkindinner/queryall")
	@ResponseBody
	public List<CheckInDinner> queryAll(@ModelAttribute CheckInDinner dinner,
			@RequestParam(name = "startDate", required = false) Date startDate,
			@RequestParam(name = "endDate", required = false) Date endDate) {
		return dinnerM.queryAll(dinner, startDate, endDate);
	}

}

